/**
 * Copyright ©2012-2018 HopeHaiyang Corporation, All Rights Reserved
 * http://www.wuhanhope.com
 */
package hope.platform.data.server.data.img;

import hope.platform.data.dao.SiteTypeRepository;
import hope.platform.data.domain.SiteType;
import hope.platform.data.server.data.header.SiteTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * class info
 *
 * @author hujia
 *         Create at 2018/7/16 14:12
 */
@Service
public class SiteTypeServiceImg implements SiteTypeService {

    @Autowired
    private SiteTypeRepository repository;

    @Override
    public SiteType addSiteType(SiteType siteType) {
        siteType.setGmtCreate(new Date());
        siteType.setGmtModified(new Date());
        return repository.save(siteType);
    }

    @Override
    public SiteType updateSiteType(SiteType siteType) {
        SiteType tmp = repository.findBySiteType(siteType.getSiteType());
        tmp.setGmtModified(new Date());
        return repository.save(tmp);
    }

    @Override
    public List<SiteType> getAllSiteType() {
        return repository.findAll();
    }
}
